import { defineStore } from 'pinia'
import { ref, computed, watch } from 'vue'
import {setCookie,getCookie,removeCookie} from '@/utils/cookie.js'

export const useFramStore = defineStore('farm', () => {
    
    // 气象服务，左侧列表选择数据
    const weacherFarmItem = ref({})
    const set_weacherFarmItem = (item)=>{
        weacherFarmItem.value = item
    }

    // 页面及tab标题
    const pageTitle = ref('')
    const set_pageTitle = data =>{
        pageTitle.value = data
    }

    // 记录需要返回的页面
    const backUrl = ref(getCookie('backUrl') )
    const set_backUrl = path =>{
        setCookie('backUrl',path)
        backUrl.value = path
    }

    return{
        weacherFarmItem,
        set_weacherFarmItem,
        pageTitle,
        set_pageTitle,
        backUrl,
        set_backUrl
    }
})